package com.atlin.project.fileService;

import com.atlin.project.common.ErrorCode;
import com.atlin.project.config.AtLinConfig;
import com.atlin.project.exception.BusinessException;
import com.atlin.project.fileService.service.MinioFileService;
import com.atlin.project.fileService.service.NativeFileService;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * @author atlin
 * @description 文件服务管理
 * @createDate 2025/1/1 10:34
 */
@Component
public class FileServiceManager {

    @Resource
    private AtLinConfig atLinConfig;

    @Resource
    private NativeFileService nativeFileService;

    @Resource
    private MinioFileService minioFileService;

    public BaseFileService getFileService() {
        switch (atLinConfig.getFileService()) {
            case "native":
                return nativeFileService;
            case "minio":
                return minioFileService;
            default:
                throw new BusinessException(ErrorCode.SYSTEM_ERROR, "不支持的类型");
        }
    }
}
